package main

import (
	"net"
	"fmt"
	"os"
)

var (
	host = "127.0.0.1"
	port = "9999"
)

func main() {
	addr, err := net.ResolveUDPAddr("udp", host+":"+port)
	if err != nil {
		fmt.Println("Can't resolve address: ", err)
		os.Exit(1)
	}

	conn, err := net.DialUDP("udp", nil, addr)
	if err != nil {
		fmt.Println("Can't dial:", err)
		os.Exit(1)
	}

	defer conn.Close()
	_, err = conn.Write([]byte("Hello Udp"))

	if err != nil {
		fmt.Println("failed: ", err)
		os.Exit(1)
	}

	fmt.Print("Send successful!")
	os.Exit(0)
}
